// Include this header before using any STL header when using Kylix 3 with newer
// distributions.
// The code was taken from the stdlib.h that comes with Kylix 3.

#if !defined(__K3STL_H__)
#define __K3STL_H__

#if !defined(__MINMAX_DEFINED)
#define __MINMAX_DEFINED

#undef min  /* make sure these aren't macros */
#undef max

#ifdef __cplusplus

extern "C++" {

namespace std {

/** Note: in C++ we implement min and max as template functions. */
template <class _T> inline const _T  &min( const _T &__t1, const _T &__t2 )
{
    if  (__t1 < __t2)
	return __t1;
    else
	return __t2;
}

template <class _T> inline const _T  &max( const _T  &__t1, const _T  &__t2 )
{
    if  (__t1 > __t2)
	return __t1;
    else
	return __t2;
}

} /* namespace std */

} /* C++ */

using std::min;
using std::max;

#else /* __cplusplus */

#define max(__a,__b)    (((__a) > (__b)) ? (__a) : (__b))
#define min(__a,__b)    (((__a) < (__b)) ? (__a) : (__b))

#endif /* __cplusplus */

#endif /* __MINMAX_DEFINED */

#endif /* __K3STL_H__ */
